﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using SES.CMS.BL;
using SES.CMS.DO;


namespace SES.CMS.AdminCP.PageUC
{
    public partial class ucListProductCollection : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            gvBoSuuTapDataSource();
        }

        protected void gvBoSuuTapDataSource()
        {
            gvBoSuuTap.DataSource = new cmsCollectionBL().SelectAll();
            gvBoSuuTap.DataBind();
        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            Response.Redirect("Default.aspx?Page=ProductCollection");
        }


        protected void gvBoSuuTap_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            new cmsCollectionBL().Delete(new cmsCollectionDO { CollectionID = Convert.ToInt32(gvBoSuuTap.DataKeys[e.RowIndex].Value) });
            Functions.Alert("Xóa bản ghi thành công", Request.Url.ToString());
        }

        protected void gvBoSuuTap_SelectedIndexChanged(object sender, EventArgs e)
        {
            int CollectionID = int.Parse(gvBoSuuTap.DataKeys[gvBoSuuTap.SelectedIndex].Value.ToString());
            Response.Redirect("Default.aspx?Page=ProductCollection&ProductCollectionID=" + CollectionID.ToString());
        }

        protected void gvBoSuuTap_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvBoSuuTap.PageIndex = e.NewPageIndex;
            gvBoSuuTapDataSource();
        }
    }
}